package com.ykl.base.jpa;

import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;

@Data
@SuperBuilder
@MappedSuperclass
public abstract class AbstractOlapEntity implements Serializable {

    /**
     * SPC_ROOM	ROOM_ID	机房ID	机房关键字ID, 该ID全网唯一。	CHAR(24)	M
     */
    @Id
    @org.springframework.data.annotation.Id
    @GeneratedValue(generator = "snowflakeIdentifierGenerator",
            strategy = GenerationType.IDENTITY)
    @GenericGenerator(
            name = "snowflakeIdentifierGenerator",
            strategy = "com.ykl.base.jpa.SnowflakeIdentifierGenerator"
    )
    @Column(
            name = "ID",
            columnDefinition = "VARCHAR(24) COMMENT 'olap中事实或指标id.'",
            nullable = false
    )
    @ApiModelProperty(value = "olap id",notes = "olap中事实或指标id.")
    private String id;

    @Column(
            name = "CTM",
            columnDefinition = "BIGINT COMMENT '创建时间戳.'",
            nullable = false
    )
    @ApiModelProperty(value = "创建时间戳")
    @Builder.Default
    private long ctm=System.currentTimeMillis();

    @Column(
            name = "MTM",
            columnDefinition = "BIGINT COMMENT '修改时间戳.'",
            nullable = false
    )
    @ApiModelProperty(value = "修改时间戳")
    @Builder.Default
    private long mtm=System.currentTimeMillis();

}
